import {
  Component, OnInit, ViewEncapsulation, ChangeDetectionStrategy, Output, EventEmitter,
  Input
} from '@angular/core';

@Component({
  selector: 'select-status',
  templateUrl: './select-status.component.html',
  styleUrls: ['./select-status.component.scss'],
  encapsulation: ViewEncapsulation.None
})
export class SelectStatusComponent implements OnInit {
  @Output() private outputStatus = new EventEmitter();
  @Input () typeList ;
  @Input () statusList ;
   public statusActive ;
   public selectData = {
     status: {name: '' , value: ''},
     type: {name: '' , value: ''}
   };
   public dataIndex: -1;

  public dataIndex0 = -1;
  public dataIndex1 = -1;

  constructor() { }
  selectStatus (i) {
   this.statusActive = i;
  }

  chooseDataIndex(v, index , name) {
    if (this.statusActive === 0) {
      this.selectData.status.value = v;
      this.selectData.status.name = name;
      this.dataIndex0 = index;
    }else {
      this.selectData.type.value = v;
      this.selectData.type.name = name;
      this.dataIndex1 = index;
    }
    this.statusActive = -1 ;
    this.outputStatus.emit(this.selectData);
  }
  ngOnInit() {

  }

}
